const {defineConfig} = require('@vue/cli-service')
const path = require('path')
const resolve = dir => path.join(__dirname, dir)

// 引入等比适配插件
const pxToRem = require('postcss-pxtorem');
// 配置基本大小
const postcss = pxToRem({
    rootValue: 40,
    propList: ['*'],
    selectorBlackList: ['.norem']
})
module.exports = defineConfig({
    lintOnSave: false,
    transpileDependencies: true,
    devServer: {
        port: 7858,
        proxy: {
            '/api': {
                target: 'http://localhost:22010',
                changeOrigin: true,
                pathRewrite: {"^/api": "/api"}
            }
        }
    },
    chainWebpack(config) {
        // set svg-sprite-loader
        config.module
            .rule('svg')
            .exclude.add(resolve('src/icons'))
            .end();
        config.module
            .rule('icons')
            .test(/\.svg$/)
            .include.add(resolve('src/icons'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({
                symbolId: 'icon-[name]',
            })
            .end()
    },
    css: {
        // 使用css分离插件 ExtractTextPlugin
        extract: true,
        // 开启 CSS source maps
        sourceMap: false,
        // css预设器配置项
        loaderOptions: {
            postcss: {
                postcssOptions: {
                    plugins: [
                        postcss
                    ]
                },
            }
        }
    }
})